	<layout name="newlayout" />
<STYLE>
   .clear {  clear: both;   }
	.input_class{width:15px;height:10px;}
.num{margin: 0 5px 0 0;padding: 3px 6px;color: #57a000;text-decoration: none;border: 1px solid #ddd;-webkit-border-radius: 4px;border-radius: 4px;}
.current{margin: 0 5px 0 0;padding: 3px 6px;color: #57a000;text-decoration: none;border: 1px solid #ddd;-webkit-border-radius: 4px;border-radius: 4px;background: #469400 url('{__IMG__}bg-button-green.gif') top left repeat-x !important;border-color: #459300 !important;color: #fff !important;}
.star{color:red;}
	.adver{margin-left:10px;}
	.adver ul{overflow:hidden;}
	.adver ul li{width:180px;height:185px;float:left;margin-left:10px;list-style:none;}
	.adver-img{width:167px;height:125px;}
#myModal{
	display: block;
left: 50%;
margin-left: -223px;
z-index: 1002;
position: fixed;
top: 50%;
margin-top: -159px;
-moz-border-radius: 6px;
background: #eef2f7;
-webkit-border-radius: 6px;
border: 1px solid #536376;
-webkit-box-shadow: rgba(0,0,0,.6) 0px 2px 12px;
-moz-box-shadow: rgba(0,0,0,.6) 0px 2px 12px;
padding: 14px 22px;
width: 400px;
display: none;}
	#img_preview{width: 167px; height: 125px;}
	.show_img a{position:relative;}
	.show_img div{display:none; position: absolute;background:#eee;border:1px solid #eee;max-width:400px;max-height:300px;padding:10px;-webkit-border-radius: 6px;border-radius: 6px;}
	.show_img div img{max-width:400px;max-height:300px;}
 #file_upload{margin:0 auto;}
	</STYLE>
	<div id="main-content"> <!-- Main Content Section with everything -->
			<!-- Page Head -->
			<div class="content-box"><!-- Start Content Box -->
				<div class="content-box-header">
					<h3>友情链接列表</h3>
					<div class="clear"></div>
				</div> <!-- End .content-box-header -->
				<div class="content-box-content">
					<div class="tab-content default-tab" id="tab1"> <!-- This is the target div. id must match the href of this div's tab -->
						<div class="notification attention png_bg">
							<a href="#" class="close"><img src="__IMG__cross_grey_small.png" title="Close this notification" alt="close" /></a>
							<div>
								提示！！
							</div>
						</div>
						<table>
							<thead>
								<tr>
									<th>排序</th>
								   <th>ID</th>
								   <th>标题</th>
								   <th>发表用户</th>
								   <th>日期</th>
								   <th>操作</th>
								</tr>
							</thead>
							<tfoot>
								<tr>
									<td colspan="6">
										<div class="bulk-actions align-left">
												<a class="button" href="javascript:" onclick="listorder();">排序</a>
											<a class="button" href="javascript:" onclick="add_set('');">新增</a>
										</div>
										<div class="pagination">
										{$show}
										</div> <!-- End .pagination -->
										<div class="clear"></div>
									</td>
								</tr>
							</tfoot>
							<tbody>
							<form action="/admin/link/listorder" method="post" id="listorder">
									<foreach name="list" item="vo">
										<tr>
											<td><input name="listorder[{$vo.id}]" class="input_class" value="{$vo.listorder}" /></td>
											<td>{$vo['id']}</td>
											<td  class="show_img"><a href="javascript:"  >{$vo['title']}</a><div  ><img src="{$vo.imgs}"/></div></td>
											<td>{$vo.user}</td>
											<td>{$vo.up_date}</td>
											<td>
												 <a  href="javascript:"   title="Edit"><img src="__IMG__pencil.png" alt="Edit"  onclick="imgUp({$vo.id});"/></a>
												 <a href="javascript:"  title="Delete"><img src="__IMG__cross.png" alt="Delete"  onclick="imgDe({$vo.id});"/></a> 
											</td>
										</tr>
									</foreach>
							</form>
							</tbody>
						</table>
					</div> 
				</div> 
			</div> 
		</div> 
												<!-- 						缩略图上传 -->
					<div  id="myModal"  >
					<span>新增/修改：</span>
						<a href="javascript:"   title="取消"  style="float:right;" onclick="add_set('')"><img src="__IMG__cross.png"  alt="取消"  /></a> 
							<div class="img_div" >
							<div style="margin: 0 auto; width: 167px; margin-bottom: 20px;">
								<img   src="__IMG__images.jpg"  id="img_preview">
							</div>
							<div style="width: 100%;">
								<form action="/admin/WebSet/imgUpload" method="post"	id="showDataForm" enctype="multipart/form-data">
									<input type="text" style="display: none" id="img_id" />
									<div class="col-lg-6" style="width:100%;">
										<div class="input-group" >
											<div class="col-lg-6" style="width:100%;">
												名称：<input type="text" class="text-input medium-input"  id="img_name"><br>
													链接：<input type="text" class="text-input medium-input"  id="img_url">
										<div class="input-group" >
													<input id="file_upload" name="thumb" type="file" multiple="true">
										</div>
										<div style="width:130px;margin:0 auto;">
										<a href="javascript:$('#file_upload').uploadify('cancel')" class="button" >删除</a>
										<a href="javascript:$('#file_upload').uploadify('upload')" class="button">上传</a>
										<a href="javascript:$('#file_upload').uploadify('upload')" class="button" onclick="saveImg()">保存</a>
										</div>
									</div>
										</div>
									</div>
								</form>
							</div>
							</div>
<!-- 							end 缩略图上传 -->
				</div>		
<script>
$(function() {
    $('#file_upload').uploadify({
   	 'auto'     : false,
        'swf'      : '/Public/js/uploadify.swf',    //指定上传控件的主体文件
        'uploader' : '/admin/logining/imgUpload',    //指定服务器端上传处理文件
        'onUploadSuccess' : function(file, data, response) {
            $("#img_preview").attr("src",data);
	 			$("#thumb").val(data);
        }
    });
});
//排序
function listorder(){
	$("#listorder").submit();
	  }
//展示图片
$(function(){
	$(".show_img").hover(function(){
			$(this).find("div").show();
		},function(){
			$(this).find("div").hide();
			});
});

//修改图片
	function imgUp(id){
         $.post("/admin/link/linkGetOne",{id:id},function(data){
        	 $("#img_id").val(id);
     		$("#img_name").val(data['title']);
     		$("#img_url").val(data['url']);
     		$("#img_preview").attr("src",data['imgs']);
     		 $("#myModal").slideToggle("slow");
             });
		}
	
//删除文章
function imgDe(id){
	  if(confirm("确定删除?")){
		  $.post("/admin/link/linkDe",{id:id},function(data){
	        	 location.reload();
	             });     
		  };
	  }
function add_set(id){
	$("#img_id").val(id);
	$("#img_name").val("");
	$("#img_file").val("");
	$("#img_url").val("");
	$("#thumb_url").val("");
	$("#img_preview").attr("src","/Public/images/images.jpg");
	 $("#myModal").slideToggle("slow");
}

function saveImg(){
	var id=$("#img_id").val();
	  var img=$("#img_preview").attr("src");
	var img_name=$("#img_name").val();
	var img_url=$("#img_url").val();
	  $.post("/admin/link/index",{imgs:img,title:img_name,url:img_url,id:id,},function(data){
	     	 location.reload();
	          });  
	
}

	</script>